﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LLoger;
using LimitatorInterfaces;
using LimitatorInterfaces.LoadServices;
using MicexFileLoader;

namespace LoadServices
{
    public class MicexFileLoaderFactory : LoadServiceFactory
    {
        public override ILoadService CreateLoadService(string configPath, ILogWriter logWriter)
        {
            ILoadProvider provider = new MicexFileLoadProvider();
            ConfigReader cfgReader = new ConfigReader(configPath, logWriter);
            var cfgFile = cfgReader.GetSettingValue(Res.ConfigFile);

            ILoadParser parser = new MicexFileLoadParser(
                string.IsNullOrWhiteSpace(cfgFile) ? configPath : cfgFile,
                logWriter);

            return new LoadService(provider, parser, configPath, logWriter);
        }
    }
}
